package com.game.majiang.vo;

import java.sql.Types;
import java.util.ArrayList;

import javax.sql.rowset.CachedRowSet;

import com.game.server.db.Parameter;
import com.game.server.db.ParameterType;
import com.game.server.db.SqlHelper;
import com.game.server.db.entity.Jackpot;

public class JackpotVo {

	public static ArrayList<Jackpot> select() {
		ArrayList<Jackpot> listJackpot = new ArrayList<>();
		String sql = "SELECT id,difen,jiangchi FROM jackpot";
		CachedRowSet resultSet = SqlHelper.getResultSet(sql);
		try {
			while (resultSet.next()) {
				Jackpot ja = new Jackpot();
				ja.id = resultSet.getInt("id");
				ja.difen = resultSet.getInt("difen");
				ja.jiangchi = resultSet.getInt("jiangchi");
				listJackpot.add(ja);
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return listJackpot;
	}
	
	public static void update(int id, int jiangchi) {
		String sql = "UPDATE jackpot SET jiangchi = ? WHERE id = ?";
		Parameter p1 = new Parameter(Types.INTEGER, jiangchi,ParameterType.Input);
		Parameter p2 = new Parameter(Types.INTEGER, id,ParameterType.Input);
		SqlHelper.execute(sql, p1, p2);
	}
	
}
